
import devHost from './config/dev';
import testHost from './config/test';
import prodHost from './config/prod';
import pretestHost from './config/pretest';

//环境参数，dev，pretest，test，prod
let environments = `${process.env.VUE_APP_ENV}` || 'production'
// const environments = 'production'
const apiPath = {
    informationBase: {
        development: {
            url: devHost.informationBase.url
        },
        test: {
            url: testHost.informationBase.url
        },
        production: {
            url: prodHost.informationBase.url
        },
        pretest: {
            url: pretestHost.informationBase.url
        }
    },
    operationmanagement: {
        development: {
            url: devHost.operationmanagement.url
        },
        test: {
            url: testHost.operationmanagement.url
        },
        production: {
            url: prodHost.operationmanagement.url
        },
        pretest: {
            url: pretestHost.operationmanagement.url
        }
    },
    panoramahall: {
        development: {
            url: devHost.panoramahall.url
        },
        test: {
            url: testHost.panoramahall.url
        },
        production: {
            url: prodHost.panoramahall.url
        },
        pretest: {
            url: pretestHost.panoramahall.url
        }
    },
    profile: {
        development: {
            url: devHost.profile.url
        },
        test: {
            url: testHost.profile.url
        },
        production: {
            url: prodHost.profile.url
        },
        pretest: {
            url: pretestHost.profile.url
        }
    },
    realtimemonitor: {
        development: {
            url: devHost.realtimemonitor.url
        },
        test: {
            url: testHost.realtimemonitor.url
        },
        production: {
            url: prodHost.realtimemonitor.url
        },
        pretest: {
            url: pretestHost.realtimemonitor.url
        }
    },

    substationoperation: {
        development: {
            url: devHost.substationoperation.url
        },
        test: {
            url: testHost.substationoperation.url
        },
        production: {
            url: prodHost.substationoperation.url
        },
        pretest: {
            url: pretestHost.substationoperation.url
        }
    },
    utiltools: {
        development: {
            url: devHost.utiltools.url
        },
        test: {
            url: testHost.utiltools.url
        },
        production: {
            url: prodHost.utiltools.url
        },
        pretest: {
            url: pretestHost.utiltools.url
        }
    },
    systemmanagement: {
        development: {
            url: devHost.systemmanagement.url
        },
        test: {
            url: testHost.systemmanagement.url
        },
        production: {
            url: prodHost.systemmanagement.url
        },
        pretest: {
            url: pretestHost.systemmanagement.url
        }
    },
    support: {
        development: {
            url: devHost.support.url
        },
        test: {
            url: testHost.support.url
        },
        production: {
            url: prodHost.support.url
        },
        pretest: {
            url: pretestHost.support.url
        }
    },
    sys: {
        development: {
            url: devHost.sys.url
        },
        test: {
            url: testHost.sys.url
        },
        production: {
            url: prodHost.sys.url
        },
        pretest: {
            url: pretestHost.sys.url
        }
    },
    web: {
        development: {
            url: devHost.web.url
        },
        test: {
            url: testHost.web.url
        },
        production: {
            url: prodHost.web.url
        },
        pretest: {
            url: pretestHost.web.url
        }
    },
    support: {
        development: {
            url: devHost.support.url
        },
        test: {
            url: testHost.support.url
        },
        production: {
            url: prodHost.support.url
        },
        pretest: {
            url: pretestHost.support.url
        }
    },
    topV: {
        development: {
            url: devHost.topV.url
        },
        test: {
            url: testHost.topV.url
        },
        production: {
            url: prodHost.topV.url
        },
        pretest: {
            url: pretestHost.topV.url
        }
    },
}

const apiHostMap = url => {
    if(environments === "devPub"){
        environments = "development";
    }
    return (apiPath[url] && apiPath[url][environments] ? apiPath[url][environments] : {
        url: ''
    }).url
}

export default apiHostMap;
